k = int(input())
s, c1, c2 = input().split()
# 在字符串前添加一个占位符，使索引从1开始
s = '0' + s
length = len(s) - 1  # 实际字符串长度
dp = [0] * (length + 1)
ans = 0
t = 0  # 用于统计c1的出现次数

for i in range(1, length + 1):
    if s[i] == c1:
        t += 1
    dp[i] = t
# 当满足条件时，累加结果
    if i >= k and s[i] == c2:
        # i - k + 1 是子串的起始位置
        ans += dp[i - k + 1]

print(ans)
